package com.pointi.PatternExtractor;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.pointi.emoTools.emoLicense;

public class ConfigurationData extends emoLicense
{
	public String s_target_date = "" ;
	public String s_target_ratio = "" ;
	public String s_param_list = "" ;
	public String s_param_order = "" ;
	
	public ConfigurationData() { }

	public void InitializeData()
	{
		s_target_date = "" ;
		s_target_ratio = "" ;
		s_param_list = "" ;
		s_param_order = "" ;
		super.InitializeData() ;
	}

	public ConfigurationData ReadConfXML(String strFile) throws Exception
	{
		NodeList mCATEGORY = null ;
		Node mNode = null ;
		ConfigurationData conf_data = new ConfigurationData() ;
		try
		{
			Document doc = super.ReadConfXML(strFile, conf_data) ;
			doc.getDocumentElement().normalize();
			if (doc.getDocumentElement().getNodeName().equals("configuration"))
			{
				// CONF // CATEGORY
				mCATEGORY = doc.getElementsByTagName("pattern_extractor") ;
				mNode = mCATEGORY.item(0) ;
				if (mNode.getNodeType() == Node.ELEMENT_NODE)
				{
					Element mElmnt = (Element) mNode ; // TYPE_CAST //
					conf_data.s_target_date = fnReadTerminal(mElmnt, "target_date") ;
				}
				if (mNode.getNodeType() == Node.ELEMENT_NODE)
				{
					Element mElmnt = (Element) mNode ; // TYPE_CAST //
					conf_data.s_target_ratio = fnReadTerminal(mElmnt, "target_ratio") ;
				}
				if (mNode.getNodeType() == Node.ELEMENT_NODE)
				{
					Element mElmnt = (Element) mNode ; // TYPE_CAST //
					conf_data.s_param_list = fnReadTerminal(mElmnt, "param_list") ;
				}
				if (mNode.getNodeType() == Node.ELEMENT_NODE)
				{
					Element mElmnt = (Element) mNode ; // TYPE_CAST //
					conf_data.s_param_order = fnReadTerminal(mElmnt, "param_order") ;
				}
			}
		} catch (Exception e) { e.printStackTrace() ; }		
		return conf_data;
	}

	public void WriteLogConfigurationData(ConfigurationData conf_data)
	{
		System.out.println("") ;
		System.out.println("=============== configuration ===============") ;
		//super.WriteLogConfigurationData(conf_data) ;
		System.out.println("------------- pattern-extractor -------------") ;
		System.out.println("target date	: " + this.s_target_date) ;
		System.out.println("target ratio	: " + this.s_target_ratio) ;
		System.out.println("param name	: " + this.s_param_list) ;
		System.out.println("param order	: " + this.s_param_order) ;
		System.out.println("---------------------------------------------") ;
	}
}
